package github.sf.fw.tools.db;


import github.sf.fw.tools.db.model.ResultRow;
import github.sf.fw.tools.db.model.TableInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.List;

public abstract class AbstractTableDataWriter implements TableDataWriter {

    protected final static Logger log = LoggerFactory.getLogger(AbstractTableDataWriter.class);

    protected DSProperty dsProperty;
    protected int batchSize = 1000;

    public AbstractTableDataWriter(DSProperty dsProperty) {
        this.dsProperty = dsProperty;
    }

    public int getBatchSize() {
        return batchSize;
    }

    public void setBatchSize(int batchSize) {
        this.batchSize = batchSize;
    }

    @Override
    public int writer(TableInfo tableInfo, List<ResultRow> resultRowList) {
        return 0;
    }

    /**
     * 将数据写入数据库
     *
     * @param dsConnector   数据库连接
     * @param tableInfo     表格信息（目前里面只用了TableName）
     * @param resultRowList 数据
     */
    @Override
    public void writer(DSConnector dsConnector, TableInfo tableInfo, List<ResultRow> resultRowList) {
    }

    @Override
    public void batchWrite(Object conn, TableInfo tableInfo, List<ResultRow> resultRows) {
    }

    @Override
    public void deleteData(TableInfo tableInfo) {
    }

    @Override
    public void deleteTable(TableInfo tableInfo) {
    }

    @Override
    public void doUpdate(String script, Object[] args) {
    }

    @Override
    public boolean createTable(TableInfo tableInfo) {
        return false;
    }

    @Override
    public boolean createTable(String ddl) {
        return false;
    }
}
